﻿Imports NHibernate
Imports TodoMicroSolutionPackV1.dal.dao.ubicacion
Imports TodoMicroSolutionPackV1.dal.dto
Imports TodoMicroSolutionPackV1.entidades.dal.dao
Imports TodoMicroSolutionPackV1.facturacion.dal.dao
Imports TodoMicroSolutionPackV1.productos.dal.dao
Imports TodoMicroSolutionPackV1.dal.dto.ubicacion
Imports TodoMicroSolutionPackV1.entidades.dal.dto
Imports TodoMicroSolutionPackV1.facturacion.dal.dto
Imports TodoMicroSolutionPackV1.productos.dal.dto

Namespace dal.dao
    Public Class NhibernateDAOFactory
        Private _session As ISession

        Private _constanteDAO As constanteDAO
        Private _empresaDAO As empresaDAO
        Private _puntoVentaDAO As puntoVentaDAO
        Private _localidadDAO As localidadDAO
        Private _departamentoDAO As departamentoDAO
        Private _provinciaDAO As provinciaDAO
        Private _entidadDAO As entidadDAO
        Private _comprobanteDAO As comprobanteDAO
        Private _comprobanteItemDAO As comprobanteItemDAO
        Private _precioDAO As precioDAO
        Private _productoDAO As productoDAO
        Private _stockDAO As stockDAO

        Public Sub New(ByRef session As ISession)
            _session = session
        End Sub

        Public Function getDao(Of T, ID)() As genericDAO(Of T, ID)

            If GetType(T).Name = "constante" Then
                Return getConstanteDAO()
            ElseIf GetType(T).Name = "empresa" Then
                Return getEmpresaDAO()
            ElseIf GetType(T).Name = "localidad" Then
                Return getLocalidadDAO()
            ElseIf GetType(T).Name = "departamento" Then
                Return getDepartamentoDAO()
            ElseIf GetType(T).Name = "provincia" Then
                Return getProvinciaDAO()
            ElseIf GetType(T).Name = "entidad" Then
                Return getEntidadDAO()
            ElseIf GetType(T).Name = "comprobante" Then
                Return getComprobanteDAO()
            ElseIf GetType(T).Name = "comprobanteItem" Then
                Return getComprobanteItemDAO()
            ElseIf GetType(T).Name = "precio" Then
                Return getPrecioDAO()
            ElseIf GetType(T).Name = "producto" Then
                Return getProductoDAO()
            ElseIf GetType(T).Name = "stock" Then
                Return getStockDAO()
            ElseIf GetType(T).Name = "puntoVenta" Then
                Return getPuntoVentaDAO()
            Else
                Throw New DataAccessException("No existe un Objeto de acceso de datos para el tipo " + GetType(T).ToString)
            End If
        End Function

        Public Function getConstanteDAO() As constanteDAO
            If _constanteDAO Is Nothing Then
                _constanteDAO = New constanteDAO(_session)
            End If
            Return _constanteDAO
        End Function
        Public Function getEmpresaDAO() As empresaDAO
            If _empresaDAO Is Nothing Then
                _empresaDAO = New empresaDAO(_session)
            End If
            Return _empresaDAO
        End Function
        Public Function getLocalidadDAO() As localidadDAO
            If _localidadDAO Is Nothing Then
                _localidadDAO = New localidadDAO(_session)
            End If
            Return _localidadDAO
        End Function
        Public Function getDepartamentoDAO() As departamentoDAO
            If _departamentoDAO Is Nothing Then
                _departamentoDAO = New departamentoDAO(_session)
            End If
            Return _departamentoDAO
        End Function
        Public Function getProvinciaDAO() As provinciaDAO
            If _provinciaDAO Is Nothing Then
                _provinciaDAO = New provinciaDAO(_session)
            End If
            Return _provinciaDAO
        End Function
        Public Function getEntidadDAO() As entidadDAO
            If _entidadDAO Is Nothing Then
                _entidadDAO = New entidadDAO(_session)
            End If
            Return _entidadDAO
        End Function
        Public Function getComprobanteDAO() As comprobanteDAO
            If _comprobanteDAO Is Nothing Then
                _comprobanteDAO = New comprobanteDAO(_session)
            End If
            Return _comprobanteDAO
        End Function
        Public Function getComprobanteItemDAO() As comprobanteItemDAO
            If _comprobanteItemDAO Is Nothing Then
                _comprobanteItemDAO = New comprobanteItemDAO(_session)
            End If
            Return _comprobanteItemDAO
        End Function

        Public Function getPrecioDAO() As precioDAO
            If _precioDAO Is Nothing Then
                _precioDAO = New precioDAO(_session)
            End If
            Return _precioDAO
        End Function
        Public Function getProductoDAO() As productoDAO
            If _productoDAO Is Nothing Then
                _productoDAO = New productoDAO(_session)
            End If
            Return _productoDAO
        End Function
        Public Function getStockDAO() As stockDAO
            If _stockDAO Is Nothing Then
                _stockDAO = New stockDAO(_session)
            End If
            Return _stockDAO
        End Function

        Public Function getPuntoVentaDAO() As puntoVentaDAO
            If _puntoVentaDAO Is Nothing Then
                _puntoVentaDAO = New puntoVentaDAO(_session)
            End If
            Return _puntoVentaDAO
        End Function
    End Class
End Namespace